<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;

class ProjectLayer extends Model
{
    const IMAGE_PATH = 'project-layers';

    const IMAGE_WIDTH = 1280;
    
    const LAYER_COORDINATE_KEY = 'project-layers_coordinate_';

    protected $table = 'xfy_project_layers';
    
    public static function getImageRoot()
    {
        $root = config('filesystems.disks.admin.root').'/';
        return $root;
    }

    public static function getImageRelative()
    {
        $root = config('filesystems.disks.admin.root').'/';
        return $root;
    }

    public static function getImageUrl($dbUrl)
    {
        return config('filesystems.disks.admin.url').'/'.$dbUrl;
    }

    public static function getImageHeight($realWidth, $realHeight)
    {
        $rate = self::IMAGE_WIDTH / $realWidth;

        $height = $realHeight * $rate;

        return $height;
    }
}